package com.xbongbong.parent.factory;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.parent.interfaces.TeamStrategy;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

/**
 * 团队工厂
 * @author 魏荣杰
 *
 */
@Component
@Slf4j
public class TeamDataFactory {

    @Resource
    private Map<Integer, TeamStrategy> teamStrategyMap;

    public TeamStrategy getStrategy(Integer businessType, Integer distributorMark, Integer saasMark) throws XbbException {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
            businessType = BasicConstant.ZERO;
        }
        Integer xbbRefCode = XbbRefTypeEnum.transferBusinessType4Distributor(businessType, distributorMark);
        return teamStrategyMap.get(xbbRefCode);
    }

}
